/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package uy.edu.ort.arqsw.domino;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author victor
 */
@Entity
@Table(name = "entradablog", catalog = "test", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "EntradaBlog.findAll", query = "SELECT e FROM EntradaBlog e"),
    @NamedQuery(name = "EntradaBlog.findById", query = "SELECT e FROM EntradaBlog e WHERE e.id = :id"),
    @NamedQuery(name = "EntradaBlog.findByFecha", query = "SELECT e FROM EntradaBlog e WHERE e.fecha = :fecha"),
    @NamedQuery(name = "EntradaBlog.findByTitulo", query = "SELECT e FROM EntradaBlog e WHERE e.titulo = :titulo"),
    @NamedQuery(name = "EntradaBlog.findByAutor", query = "SELECT e FROM EntradaBlog e WHERE e.autor = :autor")})
public class EntradaBlog implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "id", nullable = false)
    private Long id;
    @Column(name = "fecha")
    @Temporal(TemporalType.DATE)
    private Date fecha;
    @Size(max = 255)
    @Column(name = "titulo", length = 255)
    private String titulo;
    @Size(max = 255)
    @Column(name = "autor", length = 255)
    private String autor;
    @Lob
    @Size(max = 65535)
    @Column(name = "contenido", length = 65535)
    private String contenido;
    @JoinTable(name = "tag_entradablog", joinColumns = {
        @JoinColumn(name = "identradablog", referencedColumnName = "id", nullable = false)}, inverseJoinColumns = {
        @JoinColumn(name = "idtag", referencedColumnName = "id", nullable = false)})
    @ManyToMany
    private Collection<Tag> tagCollection;

    public EntradaBlog() {
    }

    public EntradaBlog(Long id) {
        this.id = id;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Date getFecha() {
        return fecha;
    }

    public void setFecha(Date fecha) {
        this.fecha = fecha;
    }

    public String getTitulo() {
        return titulo;
    }

    public void setTitulo(String titulo) {
        this.titulo = titulo;
    }

    public String getAutor() {
        return autor;
    }

    public void setAutor(String autor) {
        this.autor = autor;
    }

    public String getContenido() {
        return contenido;
    }

    public void setContenido(String contenido) {
        this.contenido = contenido;
    }

    @XmlTransient
    public Collection<Tag> getTagCollection() {
        return tagCollection;
    }

    public void setTagCollection(Collection<Tag> tagCollection) {
        this.tagCollection = tagCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof EntradaBlog)) {
            return false;
        }
        EntradaBlog other = (EntradaBlog) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "uy.edu.ort.arqsw.domino.EntradaBlog[ id=" + id + " ]";
    }
    
}
